import React, { FC, useEffect, useState } from'react';
import { Form,Input } from 'antd';
import {QuestionInputPropsType} from "./interface"
const PropComponent: FC<QuestionInputPropsType> = (props:QuestionInputPropsType) => {
    const {title,placeholder,onChange} = props;
    const [from]=Form.useForm()
    useEffect(()=>{
        from.setFieldsValue({title,placeholder})
    },[title,placeholder])
    function handleValueChange() {
        if (onChange) {
            onChange(from.getFieldsValue())
        }
    }
    return <Form form={from} onValuesChange={handleValueChange} initialValues={{title,placeholder}} layout='vertical'>
        <Form.Item label="标题" name="title" rules={[{ required: true, message: '请输入标题' }]}>
                 <Input/>
        </Form.Item>
        <Form.Item label="Placeholder" name="placeholder" >
                 <Input/>
        </Form.Item>
    </Form>
}
export default PropComponent;